package service;

import java.nio.channels.SocketChannel;

public abstract class IoTask {
    public final SocketChannel channel;
    /**
     * 当前关注状态值，如：SelectionKey.OP_READ
     */
    public final int ops;

    public IoTask(SocketChannel channel, int ops) {
        this.channel = channel;
        this.ops = ops;
    }

    /**
     * 交给处理IO
     * @return
     */
    public abstract boolean onProcessIo();

    /**
     * 执行过程中发生的一些异常，比如注册时出现异常等情况
     *
     * @param e 异常信息
     */
    public abstract void fireThrowable(Throwable e);
}
